<?php

require 'orm/om/BaseLeaguePeer.php';


/**
 * Skeleton subclass for performing query and update operations on the 'league' table.
 *
 * 
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    orm
 */
class LeaguePeer extends BaseLeaguePeer {
	/**
	 * 
	 * Function to check whether the league already present in the database or not
	 * Enter description here ...
	 * @param unknown_type $name
	 */
	
	public static function isAlreadyExists($name){
		
		$criteria = new Criteria();
		
		$criteria->add(LeaguePeer::NAME,$name);
		$oLeague = LeaguePeer::doSelect($criteria);
		if($oLeague){
			return TRUE;
		}else{
			return FALSE;
		}
		
	}
	public static function generateAccessCode()
	{
		//code to get random access code
					$string ="";
	    			$digits="";
	    			$letters="";
	    			
		    		 $x = range('A','Z');
		    		 $y = range('0','9');
		    		 $z = range('a','z');
				  for ($i=0;$i<=2;$i++) 
				  {
					   @$string .= $x[rand(0,count($x))];
					   @@$digits .= $y[rand(0,9)];
					   @$letters.= $z[rand(0,count($z))];
				  }
		    	$accesscode = $string.$digits.$letters;
		    	return $accesscode;
	}
} // LeaguePeer
